package com.example.testdemo.prize_recycler_view;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.example.testdemo.R;

import java.util.ArrayList;

/**
 * Created by 颜 on 04.26.026.
 * 中奖界面
 */

public class PrizeActivity extends Activity{
    private PrizeRecyclerView prizeRecyclerView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_prize);
        prizeRecyclerView = findViewById(R.id.prizeRecyclerView);
        initData();
    }

    private void initData() {
        ArrayList<PrizeMessageBean> beans = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            PrizeMessageBean bean = new PrizeMessageBean();
            bean.setPrizeMessage("预设数据" + (i + 1));
            beans.add(bean);
        }
        prizeRecyclerView.addData(beans);
        prizeRecyclerView.startHandler();
        prizeRecyclerView.setOnScrollToBottomListener(new PrizeRecyclerView.OnScrollToBottomListener() {
            @Override
            public void scrollToBottomCallback() {
                initData();
            }
        });
    }


    public void addData(View view) {
        PrizeMessageBean bean = new PrizeMessageBean();
        bean.setPrizeMessage("新数据");
        prizeRecyclerView.plugInLastData(bean);
    }
}
